<?php
session_start();
include("config.php");
set_include_path(get_include_path().":".$_CONF['pear_path']);
include("DB.php");
$dsn = $_CONF['db_type']."://".$_CONF['db_user'].":".$_CONF['db_pass'].
	"@".$_CONF['db_host']."/".$_CONF['db_db'];
$dbconnect = DB::connect($dsn);
if(PEAR::isError($dbconnect)){
	die("Database error:".$dbconnect->getMessage());	
}

function is_error($resource){
	if(PEAR::isError($resource)){
		die("db_error:".$resource->getMessage()."<br><br>".$resource->getDebugInfo());
	}
}
function dbselectall($tablename){
	global $dbconnect;
	$returnrow = array();
	$res = $dbconnect->query("select * from ".$tablename);
	is_error($res);
	while($row = $res->fetchRow(DB_FETCHMODE_ASSOC)){
	array_push($returnrow,$row);
	}
	return $returnrow;
	
}
function echotable($tabid,$tabth,$tabtd){
	echo "<table id='".$tabid."'> \n".
	"<tr> \n";
	foreach($tabth as $ectabth){
	echo "<th>".$ectabth."</th> \n";
	}
	echo "</tr> \n";
	echo "<tr> \n";
	for($j=0;$j < sizeof($tabtd); $j++){
		$tabth_sum=count($tabth);
		$tabth_check=0;
		echo "<tr> \n";
	for($i=0;$i < sizeof($tabtd[$j]);$i++){
		if($tabth_check < $tabth_sum){
		echo "<td>".$tabtd[$j][$i]."</td> \n";
		$tabth_check++;
		continue;
		}
		if($tabth_check == $tabth_sum){
		echo "</tr> \n".
		"<tr> \n".
		"<td>".$tabtd[$j][$i]."</td> \n";
		$tabth_check = 0;
		continue;
		}
		echo "</tr> \n";
	}
	}
	echo "</tr> \n".
	"</table>";	
}
function create_cmd_tab($cmd_nm,$cmd_dis_key,$cmd_dis_type,$cmd_dis_type_arg){
	
}
?>
